﻿<?php
	include '../inc/conn.php';
	include '../sendmail.php';
	session_start();
	extract($_POST);
	extract($_GET);
	unset($_POST,$_GET);
	
	if(!isset($_SESSION['logname'])){
		die("<div>User Session is missing</div>");
	}

	if (isset($act))
	{
		if (empty($modelname) || empty($customername) || empty($biosversion) || empty($biosdate) || empty($vowner) ){
			echo "<script>alert('必填的内容没有填写，导致失败！!');window.history.go(-1);</script>";
			die("必填的内容没有填写，导致失败！");
		}
		if (empty($ecversion))	$ecversion='N/A';
		if (empty($tspfw))		$tspfw='N/A';
		if (empty($threegfw))	$threegfw='N/A';
		if (empty($tvversion))	$tvversion='N/A';
		if (empty($vremark))	$vremark='N/A';
		if (empty($systemver))	$vremark='B/B';
		if ($act == 'add')
		{
			date_default_timezone_set('Asia/Shanghai');
			$dt = date("Y-m-d H:i:s");
			$uid= date("YmdHis");
			$db = new mysql();
			$sql="INSERT INTO `eng_version_control_table` (`Model_name`, `Customer`, `System_type`, `BIOS_version`, `Bios_release_date`, 
				`Owner`, `Build_Date`, `EC_version`, `REMARK`, `UID`) values('".htmlentities($modelname,ENT_QUOTES)."', '".htmlentities($customername,ENT_QUOTES)."', '"
				.htmlentities($systemver,ENT_QUOTES)."', '".trim(htmlentities($biosversion,ENT_QUOTES))."', '"
				.htmlentities($biosdate,ENT_QUOTES)."', '".htmlentities($vowner,ENT_QUOTES)."', '".$dt."', '"
				.trim(htmlentities($ecversion,ENT_QUOTES))."', '".htmlentities($vremark,ENT_QUOTES)."', '${uid}')";
			$db->query($sql);

			$vContent="	<b>机种：</b>${modelname}</br>
						<b>客户：</b>${customername}</br> 
						<b>BIOS：</b>${biosversion}</br>
						<b>EC： </b>${ecversion}</br>
						<b>IMAGE：</b>${systemver}</br></br>
						TE(${vowner})已验证<font color='green'><b>PASS</b></font>，QA验证结果<a href='http://10.100.160.166/qa_cfm.php?uid=$uid'>点这里</a></br>
						备注：${vremark}";

			//SendMail($customername." BIOS/EC/IMAGE 验证通知", $vContent, "QA");
			$param = array(
				'aSync'=>'Yes',
				'title'=>"$customername BIOS/EC/IMAGE 验证通知",
				'msg'=>$vContent,
				'to'=>'QA'
			);
			doAsyncMail($param);		
			
			echo "<script>alert('数据添加完成!');window.opener.location.reload();window.close();</script>";
		}
	}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<!-- <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">-->
	<link rel="stylesheet" href="/css/bootstrap.min.css">
	<link rel="stylesheet" href="/css/bootstrap-datetimepicker.min.css">
	<script type="text/javascript" src="/js/jquery.min.js"></script>
	<script type="text/javascript" src="/js/jquery-migrate.min.js"></script>
	<script type="text/javascript" src="/xhEditor/xheditor.min.js"></script>
	<script type="text/javascript" src="/xhEditor/xheditor_lang/zh-cn.js"></script>
	<script type="text/javascript" src="/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="/js/bootstrap-datetimepicker.min.js"></script>
<style>
<!--
.xheDialog label {
	display: inline;
}
.form-horizontal .control-label {
	width: 80px;
}
.form-horizontal .controls {
	margin-left: 20px;
}
-->
</style>

<script>
	$(function(){
		$("#addbtn").click(function(){
			if ($("#modelname").val() == ""){
				alert("机种名没有填写！");
				return false;
			}

			if ($("#customername").val() == ""){
				alert("客户名称没有填写！");
				return false;
			}

			if ($("#systemver").val() == ""){
				alert("出货系统没有填写！");
				return false;
			}

			if ($("#biosversion").val() == ""){
				alert("BIOS版本没有填写！");
				return false;
			}

			if ($("#biosdate").val() == ""){
				alert("BIOS日期没有填写！");
				return false;
			}			

			if ($("#ecversion").val() == ""){
				alert("EC版本没有填写！");
				return false;
			}
		});
		
		$('#biosdate').datetimepicker({
				format: 'yyyy/mm/dd',
				weekStart: 1,
				autoclose: true,
				startView: 2,
				minView: 2,
				pickerPosition: 'top-right'
			});	
	});
</script>

<title>添加版本管控内容</title>
</head>
<body class="background">
<?	include "admin_top.php";?>
<div class="container white-background pagecontent">
<div class="panel panel-primary">
    <div class="panel-heading">
        <h3 class="panel-title">添加版本管控内容</h3>
    </div>
    <div class="panel-body">
	<form action="add_verlist.php?act=add" method="post">
	<div class="input-group">
		<span class="input-group-addon">机种名称:</span>
		<input name="modelname" id='modelname' type="text" class="form-control">
	</div>
	<div class="input-group">
		<span class="input-group-addon">客户名称:</span>
		<input name="customername" id='customername'  type="text" class="form-control">
	</div>
	<div class="input-group">
		<span class="input-group-addon">出货系统:</span>
		<input name="systemver" id='systemver'  type="text" class="form-control">
	</div>
	<div class="input-group">
		<span class="input-group-addon">BIOS版本:</span>
		<input name="biosversion" id='biosversion'  type="text" class="form-control">
	</div>
	<div class="input-group">
		<span class="input-group-addon">BIOS日期:</span>
		<input name="biosdate" id='biosdate'  type="text" class="form-control">
	</div>
	<div class="input-group">
		<span class="input-group-addon">EC版本:</span>
		<input name="ecversion" id='ecversion'  type="text" class="form-control">
	</div>
	<div class="input-group">
		<span class="input-group-addon">管控人员:</span>
		<input name="vowner" type="text" readonly="readonly" value=<? echo $_SESSION['logchnname']; ?> class="form-control">
	</div>
	<div>备注:<br />
		<textarea name="vremark" rows="12" cols="80" class="xheditor {tools:'simple',skin:'default', upImgUrl:'upload.php?immediate=1'}" style="width:100%;height:280px; no-repeat right bottom fixed">
		</textarea>
	</div>
	<div>	<input class="btn btn-success btn-primary" name="submit" value="提交" type="submit" id='addbtn'>
		<input class="btn btn-danger" name="reset" value="重填" type="reset"></div>
</form>
</div>
</div>
</div>
<?
include '../bottom.php';
?>
</body>
</html>
